package aam.model.member;

import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class MemberDaoImpl implements MemberDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;

	public MemberVO login(MemberVO vo) throws Exception {
		return sqlSessionTemplate.selectOne("member.login", vo);
	}
	
	public void updatePoint(MemberVO vo) 
	{
		System.out.println("update ok");
		sqlSessionTemplate.update("admin.updatePoint", vo);
	}
	public MemberVO getMemberInfo(String id) {
		return sqlSessionTemplate.selectOne("member.getMemberInfo", id);
	}
	public String ajaxIdCheck(String id) throws Exception {
		return this.sqlSessionTemplate.selectOne("member.ajaxIdCheck", id);
	}
	public String ajaxNickCheck(String nick) throws Exception {
		return this.sqlSessionTemplate.selectOne("member.ajaxNickCheck", nick);
	}
	public int registerMember(MemberVO mvo) throws Exception {
		return this.sqlSessionTemplate.insert("member.registerMember",mvo);
	}
	@Override
	public List<MemberVO> memberList() throws Exception {
		return this.sqlSessionTemplate.selectList("admin.memberList");
	}
	
	@Override
	public int checkAttend(String id) throws Exception {
		return this.sqlSessionTemplate.insert("member.checkAttend", id);
	}

	@Override
	public String SelectcheckAttend(String id) throws Exception {
		return this.sqlSessionTemplate.selectOne("member.SelectcheckAttend", id);
	}

	@Override
	public void checkPointUp(String id) throws Exception {
		this.sqlSessionTemplate.update("member.checkPointUp", id);
	}
	public void updateGrade(MemberVO mvo) {
		this.sqlSessionTemplate.update("member.updateGrade",mvo);
	}
	@Override
	public void updateUserInfo(MemberVO mvo) throws Exception 
	{
		sqlSessionTemplate.update("member.updateUserInfo", mvo);
	}
	@Override
	public int memberdelete(String id) throws Exception {
		return this.sqlSessionTemplate.delete("admin.memberdelete", id);
	}

	@Override
	public int updateMember(MemberVO mvo) throws Exception {
		return this.sqlSessionTemplate.update("admin.updateMember", mvo);
	}
	@Override
	public int getMessageTotalConunt(String id) throws Exception {
		return this.sqlSessionTemplate.selectOne("member.getMessageTotalConunt",id);
	}
	
	@Override
	public int sendMessageTotalConunt(String id) throws Exception {
		return this.sqlSessionTemplate.selectOne("member.sendMessageTotalConunt", id);
	}

	@Override
	public List<MessageVO> getMessage(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectList("member.getMessage", map);
	}

	@Override
	public List<MessageVO> sendMessage(HashMap map) throws Exception {
		return this.sqlSessionTemplate.selectList("member.sendMessage", map);
	}

	@Override
	public String ajaxMessageFindByNick(String nick) throws Exception {
		return this.sqlSessionTemplate.selectOne("member.findByNick", nick);
	}

	@Override
	public int forwardingMessage(HashMap map) throws Exception {
		return this.sqlSessionTemplate.insert("member.forwardingMessage", map);
	}

	@Override
	public MessageVO getMessageInfo(int no) throws Exception {
		return this.sqlSessionTemplate.selectOne("member.getMessageInfo", no);
	}

	@Override
	public MessageVO sendMessageInfo(int no) throws Exception {
		return this.sqlSessionTemplate.selectOne("member.sendMessageInfo", no);
	}

	@Override
	public MessageVO getDeleteCheck(int no) throws Exception {
		return this.sqlSessionTemplate.selectOne("member.getDeleteCheck", no);
	}

	@Override
	public int getDeleteCheckUpdate(int no) throws Exception {
		return this.sqlSessionTemplate.update("member.getDeleteCheckUpdate", no);
	}

	@Override
	public MessageVO sendDeleteCheck(int no) throws Exception {
		return this.sqlSessionTemplate.selectOne("member.sendDeleteCheck", no);
	}

	@Override
	public int sendDeleteCheckUpdate(int no) throws Exception {
		return this.sqlSessionTemplate.update("member.sendDeleteCheckUpdate", no);
	}

	@Override
	public int deleteMessage(int no) throws Exception {
		return this.sqlSessionTemplate.delete("member.deleteMessage", no);
	}
	@Override
	public MemberVO nickCheck(String nick) throws Exception {
		return this.sqlSessionTemplate.selectOne("admin.nickCheck",nick);
	}
	@Override
	public List<String> gradeList() throws Exception {
		return this.sqlSessionTemplate.selectList("admin.gradeList");
	}
}
